home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tricks of the Mac Game Programming Gurus
/
TricksOfTheMacGameProgrammingGurus.iso
/
Book Chapters
/
10 - Networking
/
NovelNetwar
/
appleEvents.c
next >
Wrap
Text File
|
1995-05-12
|
3KB
|
141 lines
// This module implements minimal support for Apple Events
// Is it just me, or is it really a huge pain to do anything serious with Apple Events?
// Another program I've written uses AppleEvents to communicate with Eudora, and it nearly
// killed me to get it to work.... The AppleEvent documentation makes my head hurt. =(
#include "NovelNetwar.h"
#include <AppleEvents.h>
#include <GestaltEqu.h>
pascal OSErr AEOpenHandler(AppleEvent *messagein, AppleEvent *reply, long refIn);
pascal OSErr AEOpenDocHandler(AppleEvent *messagein, AppleEvent *reply, long refIn);
pascal OSErr AEPrintHandler(AppleEvent *messagein, AppleEvent *reply, long refIn);
pascal OSErr AEQuitHandler(AppleEvent *messagein, AppleEvent *reply, long refIn);
void appleEventsInit(void)
{
OSErr errCode;
long aLong;
char tempString[256];
if (Gestalt(gestaltAppleEventsAttr, &aLong) == noErr)
{
errCode = AEInstallEventHandler(kCoreEventClass,kAEOpenApplication,AEOpenHandler, 0, FALSE);
if (errCode != noErr)
{
sprintf(tempString,"appleEventsInit: AEInstallEventHandler() error %d",errCode);
ErrorAlert(tempString);
}
errCode = AEInstallEventHandler(kCoreEventClass,kAEOpenDocuments,AEOpenDocHandler, 0, FALSE);
if (errCode != noErr)
{
sprintf(tempString,"appleEventsInit: AEInstallEventHandler() error %d",errCode);
ErrorAlert(tempString);
}
errCode = AEInstallEventHandler(kCoreEventClass,kAEQuitApplication,AEQuitHandler, 0, FALSE);
if (errCode != noErr)
{
sprintf(tempString,"appleEventsInit: AEInstallEventHandler() error %d",errCode);
ErrorAlert(tempString);
}
errCode = AEInstallEventHandler(kCoreEventClass,kAEPrintDocuments,AEPrintHandler, 0, FALSE);
if (errCode != noErr)
{
sprintf(tempString,"appleEventsInit: AEInstallEventHandler() error %d",errCode);
ErrorAlert(tempString);
}
}
}
void appleEventsStartup(void)
{
}
void appleEventsShutDown(void)
{
}
void DoHighLevel(EventRecord *AERecord)
{
int errCode;
char tempString[256];
errCode = AEProcessAppleEvent(AERecord);
if (errCode != noErr)
{
sprintf(tempString,"DoHighLevel: AEProcessAppleEvent() error %d",errCode);
// ErrorAlert(tempString);
}
}
pascal OSErr AEOpenHandler(AppleEvent *messagein, AppleEvent *reply, long refIn)
{
return(errAEEventNotHandled);
}
pascal OSErr AEOpenDocHandler(AppleEvent *messagein, AppleEvent *reply, long refIn)
{
return(errAEEventNotHandled);
}
pascal OSErr AEPrintHandler(AppleEvent *messagein, AppleEvent *reply, long refIn)
{
return(errAEEventNotHandled);
}
pascal OSErr AEQuitHandler( AppleEvent *messagein, AppleEvent *reply, long refIn )
{
alive = FALSE;
return(noErr);
}